<include file="Common:pony" />
<body>
<include file="Common:sellerpanel" />
<h2>待发货订单</h2>
<form id="form1" name="form1" method="post" action="<{:U('tradesave')}>">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#999999">
<tr class="header">
<th width="120" height="30">订单号</th>
<th width="120">买家帐号</th>
<th>收货地址</th>
<th width="120">卖家备注<br>
  买家留言</th>
<th width="130">商品信息</th>
<th width="100">快递</th>
<th>订单金额<br>
  总成本</th>
<th width="100">提交时间</th>
</tr>
<php>
if( $tradelist ) {
	
	foreach( $tradelist as $trade ) {
		$ordersinfo = '';
		$orders = unserialize( $trade['orders'] );		
		foreach(  $orders['order'] as $t=>$order ){
			$ordersinfo .= '<div>'. ($t+1).'.'. $order['outer_sku_id'] .'('.$order['num'] .'件)</div>';
		}
		$company = D('Company')->where("id={$trade['syscomid']}")->getField('name');
		$tradeflag = tradeflag( $trade['seller_flag'] );
		echo '<tr class="row">
		<td height="50" align="center">'. $trade['tid']. '</td>
		<td align="center">'. $trade['buyer_nick'] .'<br>'. contacttuser( $trade['buyer_nick'] ) . '</td>
		<td>'. $trade['receiver_name'] .','. $trade['receiver_mobile'] . ','. $trade['receiver_phone'] .',' . $trade['receiver_state'] .', '. $trade['receiver_city']. ' '. $trade['receiver_district'] .','. $trade['receiver_address'] .','. $trade['receiver_zip'] . '</td>
		<td align="center"><span style="color:red">'. $tradeflag . ' '. $trade['seller_memo'] . '</span><br><span style="color:blue">' . $trade['buyer_message'] .'</span></td>
		<td>'. $ordersinfo .'</td>
		<td align="center">'. $company .'</td>
		<td align="center">' .$trade['payment']. '/'. $trade['syscost'] .' </td>
		<td align="center">' .$trade['sysaddtime']. '</td></tr>';
	} 
}
</php>
<tr class="row">
<td colspan="8" height="30" align="center"><div><{$page}></div></td>
</tr>
</table>

<script>
$(document).ready(function(){
	$("select[id^='company_']").bind('change', function(){
		var tplid = $(this).val();
		var tid   = $(this).attr( 'alt' );
		$.post ( '<{:U('Index/price')}>', { trade : $("#tradedata_" + tid ).val() , tplid: tplid }  ,
			function(data){
				if( 1 == data['status'] ) {
					$('#chengben_'+tid).html( data['data']['cost'] );	
				} else {
					alert( data['info']);
				}
			 	
			}	
		); 
	});
	
	
	
	$("input[id^='btnPostTrade']").bind('click', function(){
		var tid = $(this).attr( 'alt' );
		var tplid = parseInt( $( '#company_'+tid ).val() );
		if( null == tplid || 0 == tplid ) {
			alert('选择快递模板');
			return false ;
		}
		$.post( '<{:U('Index/tradesave')}>' , {
				trade : $("#tradedata_" + tid ).val(), tplid: tplid 
			}, 
			function(data){
				if( 1 == data['status'] ){
					alert( data['info'] );
				}else {
					alert('提交失败 '+ data['info'] );	
				}
				
			} 
		);
	} );
	
	
});
</script>
</body>
</html>